/**
  * @Author: songgh
  * @Date: 2021-09-20 14:41:08
  * @LastEditors: songgh
  * @LastEditTime: 2021-09-20 15:41:08
  * @Description: App
  */
import { defineComponent, onMounted, KeepAlive } from "vue";
import { useStore } from "vuex";
import { RouterView } from "vue-router";

export default defineComponent({
    name: "App",
    setup() {
        const store = useStore();
        onMounted(() => {
            window.addEventListener('beforeunload', () => {
                sessionStorage.setItem("store", JSON.stringify(store.state));
            });
            if (sessionStorage.getItem('store')) {
                store.replaceState(Object.assign(store.state, JSON.parse(sessionStorage.getItem('store'))));
            }
        });
        return {}
    },
    render() {
        return (
            <div class="App">
                <RouterView>
                    {
                        ({ Component }) => {
                            return <KeepAlive include={['ServiceList']}>
                                <Component />
                            </KeepAlive>
                        }
                    }
                </RouterView>
            </div>
        )
    }
});
